package cate.game.play.skill.passive.god;

import cate.common.table.d.GD;
import cate.game.attr.FightAttr;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;
import easy.java.struct.ref.DoubleRef;

/**
 * 受击时免疫0.12*（1.1*自身pk减伤+0.2自身伤害加深）*自身当前生命值的伤害，免疫伤害不超过伤害的50%，每回合至多1次，冷却1回合
 */
public class 受之转化PH extends PassiveHandler {


	private double 系数;

	private double 减伤系数;

	private double 加伤系数;

	private double 最大系数;

	//系数=1200&减伤系数=11000&加伤系数=2000&最大系数=50000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		系数 = args.getWDouble("系数", 0d);
		减伤系数 = args.getWDouble("减伤系数", 0d);
		加伤系数 = args.getWDouble("加伤系数", 0d);
		最大系数 = args.getWDouble("最大系数", 0d);
	}

	private int lastRound;

	@Override
	public void adjustSkillDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		if (lastRound >= action.getRound().index) {
			return;
		}
		lastRound = action.getRound().index;
		FightAttr total = skill.owner.attr.total();
		double ignHurt = 系数 * (减伤系数 * total.pvpDown() + 加伤系数 * total.damageAdd()) / GD.W_10000_0 * total.hpCur();
		double max = doubleRef.v * 最大系数;
		ignHurt = Math.min(ignHurt, max);
		doubleRef.v -= ignHurt;
	}
}
